package edu.java.lectures.lec07.coupling.printing;

// expose minimal ammount information about the internal structure and implementation
//of the class

// Definition: Coupling is the degree to which one class knows about another class.

// EDIN KLAS NE TRQBWA DA ZNAE KAK E IMPLEMENTIRAN DRUG KLAS. TRQBWA DA ZNAE 
// SAMO METODITE NA INTERFEJSA MU
public class PrinterHandler implements Printirasht {

    private String contentToPrint;

    public PrinterHandler() {
    }

    // public void print(Document doc) {
    // printImpl(doc.getContent());
    // }
    //
    // public void print(Picture picture) {
    // printImpl(picture);
    // }

    @Override
    public void print(Printable printableObj) {
	establishConnection();
	findPrinter();
	sendContentToPrinter(printableObj.getPrintableContent());
	triggerPrinting();
	closeConnection();
    }

    // 1
    private void establishConnection() {
	// establish connection;
    }

    // 2
    private void findPrinter() {
	// finding printer
    }

    // 3
    private void sendContentToPrinter(String content) {
	// send content to printer
	contentToPrint = content;
    }

    // 4
    private void triggerPrinting() {
	// do printing
	System.out.println(contentToPrint);
	contentToPrint = null;
    }

    // 5
    private void closeConnection() {
	// close connection;
    }

}
